//
//  SNAllNotifyCell.m
//  app
//
//  Created by 王少宁 on 15/9/8.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "SNAllNotifyCell.h"

@interface SNAllNotifyCell ()
@property (nonatomic, strong) UILabel * titleLabel;
@property (nonatomic, strong) UILabel * isTopLabel;
@property (nonatomic, strong) UILabel * timeLabel;
@end

@implementation SNAllNotifyCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor redColor];
        _titleLabel.font = JKAppGlobleFontSmallTagText;
        [self.contentView addSubview:_titleLabel];
        
        _isTopLabel = [[UILabel alloc] init];
        _isTopLabel = [[UILabel alloc] init];
        _isTopLabel.textColor = [UIColor redColor];
        _isTopLabel.font = [UIFont systemFontOfSize:7.0f];
        _isTopLabel.layer.borderColor = [UIColor redColor].CGColor;
        _isTopLabel.layer.borderWidth = UP(1);
        _isTopLabel.textAlignment = NSTextAlignmentCenter;
        _isTopLabel.text = @"置顶";
        _isTopLabel.backgroundColor = [XCommon hexStringToColor:@"#ffebed"];
        [self.contentView addSubview:_isTopLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 100, 0, 90, kAllNotifyCellH)];
        _timeLabel.textColor = [XCommon hexStringToColor:kColor_m_light_gray_text];
        _timeLabel.font = [UIFont systemFontOfSize:9.0f];
        _timeLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_timeLabel];
    }
    return self;
}

- (void)cellWithModel:(SNAllNotifyModel *)model
{
    _titleLabel.text = model.title;
    [_titleLabel sizeToFit];
    CGFloat titleLabelW = _titleLabel.ubo.width;
    if (_titleLabel.ubo.width > SCREEN_WIDTH * 0.65) {
        titleLabelW = SCREEN_WIDTH * 0.65;
    }
    _titleLabel.frame = CGRectMake(10, 0, titleLabelW, kAllNotifyCellH);
    
    if (model.isTop) {
        _isTopLabel.frame = CGRectOf([_titleLabel.ufo fx:1.0 ox:5 fy:0 oy:(kAllNotifyCellH - 12) * 0.5],
                                     [_titleLabel.ubo ow:18 oh:12]);
    }
    
    _timeLabel.text = model.createtime;
}

- (void)drawRect:(CGRect)rect
{
    [self drawSeperatorLineLeft:10 right:10];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
